export function isEmpty1(str) {
  if (str !== undefined && str !== null && str.toString().length > 0) {
    return false;
  } else {
    return true;
  }
}

export function thousandthForamt(value, defValue, n, bol){
  if (value) {
    if(!isNaN(value) && typeof value === 'number') {
      if(n || n === 0){
        value = value.toFixed(n).toString()
      } else {
        value = value.toString()
      }
    } else {
      if(n || n === 0){
        value = parseFloat(value).toFixed(n).toString()
      }else{
        value = parseFloat(value).toString()
      }
    }
    if(bol){
      value = value.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g,'$&,');
    }
    return value;
  }else if(value === null || value === undefined || value === ''){
    if(defValue || defValue === 0){
      if(n || n === 0){
        return defValue.toFixed(n)
      }
      return defValue
    }else{
      return ''
    }
  }else if(value === 0){
    if(n || n === 0){
      return value.toFixed(n)
    }
    return value
  }
}

export function formatter(value){
  if (value === null || value === undefined) return "";
  return (localStorage.getItem("thousandsSeparator") == 1 ? value.replace(/\B(?=(\d{3})+(?!\d))/g, ',') : value.replace(/\$\s?|(,*)/g, ''))
}
export function parser(value){
  return value.replace(/\$\s?|(,*)/g, '')
}